package com.mayundev.pa.controller;

import com.mayundev.pa.model.ChatRequestEntity;
import com.mayundev.pa.model.ChatResponseEntity;
import com.mayundev.pa.service.AIService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

@RestController
@RequestMapping("/api")
@CrossOrigin
public class AIController {
    
    @Autowired
    private AIService aiService;

    @PostMapping("/simpleChat")
    public ChatResponseEntity chat(@RequestBody ChatRequestEntity request) {
        return aiService.simpleChat(request);
    }

    @PostMapping(value = "/chat", produces = MediaType.APPLICATION_STREAM_JSON_VALUE)
    public Flux<ChatResponseEntity> chatStream(@RequestBody ChatRequestEntity request) {
        return aiService.chatStream(request);
    }
}
